<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<link href="/ANDF/resources/css/New-project.css" rel="stylesheet" type="text/css" />
		<%--<%@ include file="/resources/common/jqGrid.jsp"%>--%>
<script type="text/javascript">
$(function() {
	var h = document.documentElement.clientHeight - 193 - 16 - 8;
	$("#Donors-search").attr("style", "height:" + h + "px;");
	var w = document.documentElement.clientWidth - 229 - 23 - 31 - 12 - 6;
	$(".content-centerBG").attr("style", "width:" + w + "px;");
	$(window).resize(function(){//宽度自适应方法
		var h = document.documentElement.clientHeight - 193 - 16 - 8;
		$("#Donors-search").attr("style", "height:" + h + "px;");
		var w = document.documentElement.clientWidth - 229 - 23 - 31 - 12 - 6;
		$(".content-centerBG").attr("style", "width:" + w + "px;");
	}); 
	$(".content-centerBG").resize(function(){
		changeGrid();
	});
	data_load();
})
function changeGrid(){
	var parentWidth=parseInt($(".content-centerBG").css("width").toString().split("px"));
	$("#list").setGridWidth(parentWidth*0.99);//jqGrid随父元素宽度自适应
}

/** 格式化state */
function stateFmt(data, qw, qwe) {
	//1是新建，2是审核中，3是有效项目，4是归档
	if (data == 1) {
		return "新建";
	}
	if (data == 2) {
		return "审核中";
	}
	if (data == 3) {
		return "有效项目";
	}
	if (data == 4) {
		return "归档";
	}
}

/**添加 */
function doAddProject() {
	$().jumpUrl("/pages/projectManagement/projectManagementForm.jsp");
}

/**添加 */
function del() {
	var id = $("#list").jqGrid('getGridParam', 'selarrrow');
	$.post('<%=request.getContextPath()%>/barCodeManage/remove_barCodeConditions.action', {
		"id" : id.toString()
	}, function(data) {
		url = "<%=request.getContextPath()%>/barCodeManage/list_barCodeConditions.action";
		$("#list").jqGrid('setGridParam', {
			url : url
		}).trigger("reloadGrid");//重新载入数据
		}, "json");
}

/**修改 */
function doEditProject() {
	var id = $("#list").jqGrid('getGridParam', 'selarrrow');
    var ids = [];
    if (null != id && id.toString() != "") {
        ids = id.toString().split(",");
    }
    if (ids.length > 0) {
        if (ids.length > 1) {
            alert("只能选择一条数据!");
        } else {
            //跳转
           $().jumpUrl("/pages/projectManagement/projectManagementForm.jsp",{id:id});
        }
    } else {
        alert("请选择一条数据!");
    }
}
function checkInfo(){
	var id = $("#list").jqGrid('getGridParam', 'selarrrow');
    var ids = [];
    if (null != id && id.toString() != "") {
        ids = id.toString().split(",");
    }
    if (ids.length > 0) {
        if (ids.length > 1) {
            alert("只能选择一条数据!");
        } else {
            //跳转
           $().jumpUrl("/pages/projectManagement/projectInfo.jsp",{id:id,src:'1'});
        }
    } else {
        alert("请选择一条数据!");
    }
}
//取消项目
function cancleProject(){
	var id = $("#list").jqGrid('getGridParam', 'selarrrow');
	if(id.length>0){
		if(confirm("确定删除选择的数据？")){
			$.post("<%=request.getContextPath()%>/projectManagement/delete_project.action",
				{"id" : id.toString()},
					function(data) {
				data_load();
			}, "json");
		}
	}else{
		alert("请选择一条数据！");
		return;
	}
	
}

function subProject(){
	var id = $("#list").jqGrid('getGridParam', 'selarrrow');
    var ids = [];
    if (null != id && id.toString() != "") {
        ids = id.toString().split(",");
    }
    if (ids.length > 0) {
        if (ids.length > 1) {
            alert("只能选择一条数据!");
        } else {
            //跳转
           $.post($().getPath() + "/projectManagement/update_projectState.action",
			{"id" : id.toString(),
        	 "state":2
        	},
				function(data) {
				data_load();
			}, "json");
        }
    } else {
        alert("请选择一条数据!");
    }
}


/** 人员选择组件 */
function doUserSelect(obj) {
    var $selectName = $(obj).openDialogW( {
        loadDateType : "userSelectComp",
        chkStyle : "radio",
        fillData : true
    }, null);
}

/** 部门选择组件 */
function doDepartSelect(obj) {
    var $selectName = $(obj).openDialogW( {
        loadDateType : "departSelectComp",
        chkStyle : "radio",
        fillData : true
    }, null);
}
/**
 * 数据加载
 * @author jiangpeng
 */
function data_load() {
    $("#list").jqGrid("clearGridData");
    var url = "<%=request.getContextPath()%>/sys/list_userLogin.action";
           
    $("#list").jqGrid( {
        url : url,
        datatype : "json",
		colNames : ['loginid', '登录名','真实姓名'],
		colModel : [ {
						name : 'loginid',
						index : 'loginid',
						hidden : true
					}, {
						name : 'loginname',
						index : 'loginname'
					}, {
						name : 'realname',
						index : 'realname'
					} ]

    }).jqGrid("setGridParam", {
        url : url
    }).trigger("reloadGrid", [ {
        page : 1
    } ]);
}
</script>

		<div class="cl">
			<div class="fl">
<%--				<a class="show-btn" title="显示"></a>--%>
				<ul>
					<li class="search-top">
						<a class="hidden-btn" title="收起"></a>
					</li>
					<li id="Donors-search" class="search-center">
						<form name="queryFrom">
							<div class="search-button">
								<button class="Btn_css" type="button" onclick="data_load();">
									查&nbsp;&nbsp;询
								</button>
							</div>
							<div
								style="margin: 20px 0 0 12px; overflow: auto; height: 320px; width: 198px;">
								<ul class="search-center-ul">
									<li>
										<label>
											登录名：
										</label>
										<span><input type="text" border="solid 1px #2c7aba"
												id="loginname" /> </span>
									</li>
									<li>
										<label>
											真实姓名：
										</label>
										<span><input type="text" border="solid 1px #2c7aba"
												id="realname" /> </span>
									</li>
								</ul>
							</div>

						</form>
					</li>
					<li class="search-bottom"></li>
				</ul>
			</div>
			<div class="fr">
				<ul>
					<li class="content-leftBG"></li>
					<li class="content-centerBG">
						<span class="content-span"><a class="content-centerBG-add"
							href="javascript:doAddProject()">
								<h4>
									添加&nbsp;
								</h4> </a><a class="content-centerBG-edit"
							href="javascript:doEditProject()">
								<h4>
									修改&nbsp;
								</h4> </a><a class="content-centerBG-delete" 
							href="javascript:del();">
								<h4>
									删除
								</h4> </a><a class="content-centerBG-detail"
							href="javascript:checkInfo()">
								<h4>
									查看&nbsp;
								</h4> </a><a class="content-centerBG-concel"
							href="javascript:cancleProject()">
								<h4>
									取消&nbsp;
								</h4> </a><a class="content-centerBG-export"
							href="javascript:subProject()">
								<h4>
									提交&nbsp;
								</h4> </a> </span>
						<div class="cl">
							<table id="list"></table>
							<div id="pager"></div>
						</div>
					</li>
					<li class="content-rightBG">
					</li>
				</ul>
			</div>
		</div>